local path "C:\Users\pgi1\Dropbox\Coal 2021 _ Joe Peter\Bank Regressions\"
cd "`path'\data"
set seed 100
set more off
clear



use  deals_vars_dataset, clear


bysort packageid ultimateparentid : keep if _n==1


// Look at BoA
// edit if ultimateparentid==186719

keep if year>=2000 & year<=2020

est clear




areg deal_amount_mtr_ln treated loans_related_lag3_ln loans_total_lag3_ln log_assets asset_growth_3 y_*, vce(cluster ultimateparentid) absorb(ultimateparentid )
est store e0
estadd local fes "Bank and Year"

areg log_allindrawn_max treated   loans_related_lag3_ln loans_total_lag3_ln log_assets asset_growth_3 y_*, vce(cluster ultimateparentid) absorb(ultimateparentid )
est store e1
estadd local fes "Bank and Year"


areg log_maturity treated  loans_related_lag3_ln loans_total_lag3_ln log_assets  asset_growth_3 y_*,  vce(cluster ultimateparentid) absorb(ultimateparentid )
est store e2
estadd local fes "Bank and Year"

areg revolver treated  loans_related_lag3_ln loans_total_lag3_ln log_assets asset_growth_3 y_*, vce(cluster ultimateparentid) absorb(ultimateparentid )
est store e3
estadd local fes "Bank and Year"


areg secured_loan treated  loans_related_lag3_ln loans_total_lag3_ln log_assets asset_growth_3 y_*, vce(cluster ultimateparentid) absorb(ultimateparentid )
est store e4
estadd local fes "Bank and Year"



esttab e0 e1 e2 e3 e4  using "`path'\tables\table-6.rtf",  replace compress nogaps se onecell b(3) modelwidth(6) ///
title("Deal Level Results: Deal Characteriostics") mtitles("Ln Deal Amount" "Ln Spread over Libor"  "Ln Maturity"  "Revolver" "Secured" ) ///
stats(fes r2_a  N , fmt(%9.0fc %9.3fc %9.0fc ) labels("Fixed Effects" "Adj. R-squared" "Observations" ) ) ///
label collabels(none)  starlevels(* 0.10 ** 0.05 *** 0.01) nonote ///
order(treated  log_assets asset_growth_3  loans_total_lag3_ln loans_related_lag3_ln) keep(treated  log_assets asset_growth_3  loans_total_lag3_ln loans_related_lag3_ln) 

